package com.gzhryc.common.config.models;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.gzhryc.common.config.I18nTools;
import com.gzhryc.common.config.I18nTools.I18n;
import com.gzhryc.common.xml.annotation.XmlElement;

@XmlElement("enum")
public class EnumEntity {

	private String key;
	@XmlElement("item")
	private List<Item> items;
	private Boolean canUpdate = false;
	
	public EnumEntity() {
		this.items = new ArrayList<Item>();
	}
	
	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public List<Item> getItems() {
		return items;
	}

	public void setItems(List<Item> items) {
		this.items = items;
	}

	public Boolean getCanUpdate() {
		return canUpdate;
	}

	public void setCanUpdate(Boolean canUpdate) {
		this.canUpdate = canUpdate;
	}



	public static class Item {
		
		private String index;
		private String name;
		private String note;
		
		public String index(){
			return this.index;
		}
		
		public String note(){
			String result = this.note;
			I18n i18n = I18nTools.getCurrentI18n();
			if(i18n != null){
				String temp = i18n.getProperties().getProperty(this.name);
				if(StringUtils.isNotBlank(temp)){
					result = temp;
				}
			}
			return result;
		}
		
		public String getIndex(){
			return index();
		}
		
		public String getNote(){
			return note();
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public void setIndex(String index) {
			this.index = index;
		}

		public void setNote(String note) {
			this.note = note;
		}
	}
}
